This specification relates in general to image processing and in particular to gamma adjustments.
An image is a 2-dimensional array of pixels values where each value encodes brightness. A color image has 3 brightness values per pixel encoding respectively, a red value, a green value and a blue value. More than three values per pixel can be recorded, e.g. if a near-infrared picture of a scene is also captured. For convenience, in this specification an image has a single brightness value per pixel location (though the methods described herein can be applied to all types of images. Further, and without loss of generality, brightness values are numbers in the range 0 to 1 (mathematically in the interval [0, 1]).
Brightness values can be changed in an image to better bring out detail. For example, often in images the details in the shadows are too dark to see. Brightening an image can make these details visible. An image can be brighten or darken in multiple ways, for example, by applying a gamma transformation to the image. The gamma transformation of an image is performed by raising the brightness values in an image to a power gamma. Let B denote brightness of an image and Bij the brightness at the (ith, jth) pixel location. The brightness of an image or pixel can be changed via a gamma adjustment (transformation) by:B→Bγ,Bij→Bijγ  (1),where γ is in (0, ∞]. In this manner, brightness values in the range [0,1] map to the same interval after the gamma correction. Sometimes changing brightness of an image via a gamma transformation according to equation (1) is called changing contrast. For example, a brightness contrast adjustment can be determined as B→αBγ. If gamma is equal to 1, greater than 1 or less than 1, then the image is unchanged, made darker and made brighter, respectively. A gamma adjustment has the advantage that the whole input brightness range is mapped to the whole output range.
FIG. 1 shows an example of a gamma transformer 150 used to perform gamma adjustments on an original image 102. For example, the original image 102 can be transformed to a darker image 104 and to a brighter image 106 by applying gamma exponents of 2 and 0.5, respectively. The gamma transformer 100 uses transfer functions 152, 154, 156 to map the input brightness range of image 102 to output brightness ranges of images 102′, 104, 106, respectively. For example, to obtain image 102′ the identity function 152, corresponding to γ=1, is used. Notice that a fractional gamma transformation 154 stretches dark values but compresses highlights, as illustrated in the output image 106. Conversely, a gamma transformation 156 which uses a gamma exponent that is bigger than 1 stretches highlights and compresses shadow detail, as illustrated in the output image 104.
The gamma transformer 150 can be implemented as part of photo-editing software programs and can provide a user with a control for adjusting gamma to change the look of an image. In this manner, detail can be brought out in the image. An image that is too dark may look better when a fractional gamma exponent is used for the applied gamma transformation. However, if a very small gamma exponent is used for the applied gamma transformation, then the highlight detail can become too compressed and the detail gained in the shadows may be achieved at the cost of loss of details in the highlights. There exist multiple ways to adjust gamma in images. If an image is, on average, bright then, intuitively, a gamma exponent larger than 1 (e.g., 154) can be selected to make the image darker. Or if the image is, on average, dark then a fractional gamma exponent (e.g., 156) can be applied.
FIG. 2 shows another example of a gamma transformer 250 used to perform gamma adjustments on original image 102. The gamma transformer 250 uses an exponent gamma defined as
                              γ          =                      2                          (                                                                    μ                    A                                    -                  0.5                                0.5                            )                                      ,                            (        2        )            
where μA is the arithmetic mean of the image brightness. When μA is equal to 0.25, 0.5 and 0.75, gamma is respectively equal to 0.701, 1 and 1.41. For example, when the original image 102 is dark on the average, a fractional gamma is used to generate a transformed image 108 brighter than the original image 102 by applying the gamma transformation associated with gamma transformer 250. When the average brightness of the original image 102 is 0.5 the image stays the same under the gamma transformation associated with gamma transformer 250. And, when the mean is greater than 0.5 the resulting gamma is larger than 1 so a transformed image 108 darker than the original image 102 is generated by applying the gamma transformation associated with gamma transformer 250. The image 108 represents the output of gamma transformer 250 for the input image 102, when the exponent gamma is 0.85 (as calculated using equation (2)). Moreover, the gamma transformer 250 can calculate the average μA by convolving the image 102 with a Gaussian filter with large support (e.g., having a standard deviation proportional to the size of the image). The resulting average μA is a blurred version of the input. Strong blurring may be needed to avoid halo artifacts in the output image.
Further by construction, the minimum fractional gamma determined based on equation (2) is 0.5 and the maximum gamma is 2. Gamma transformations having gamma exponents in this range are conservative and so the gamma transformer 250 can only make mild changes to image content. A repeater 260 can be used to return an image transformed by the gamma transformer 250 as an input image back to the gamma transformer 250 for iteratively applying the gamma adjustment corresponding to equation (2). The output of the gamma transformer 250 after 5 iterations is image 110. In using the combination of gamma transformer 250 and repeater 260, it is challenging to decide how many iterations of the gamma adjustment corresponding to equation (2) should be applied to continue improving the look of the original image 102. This challenge indicates that the gamma calculated in equation (2) is not optimal.